package com.minimalist.common.entity.basic.vo.file;

import cn.hutool.core.date.DatePattern;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.minimalist.common.config.convert.FileSizeDeserializer;
import com.minimalist.common.config.convert.FileSizeSerializer;
import com.minimalist.common.config.swagger.SchemaEnum;
import com.minimalist.common.entity.basic.enums.StatusEnum;
import io.swagger.v3.oas.annotations.media.Schema;
import java.io.Serial;
import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * @author 11987
 */
@Schema(name = "文件实体")
public class FileVO implements Serializable{

    @Serial
    private static final long serialVersionUID = 1L;

    @JsonSerialize(using = ToStringSerializer.class)
    @Schema(name = "fileId", description = "文件ID", type = "string")
    private Long fileId;

    @Schema(name = "fileName", description = "文件名", type = "string")
    private String fileName;

    @JsonSerialize(using = FileSizeSerializer.class)
    @JsonDeserialize(using = FileSizeDeserializer.class)
    @Schema(name = "fileSize", description = "文件大小", type = "string")
    private Long fileSize;

    @Schema(name = "fileType", description = "文件类型", type = "string")
    private String fileType;

    @Schema(name = "fileUrl", description = "文件URL", type = "string")
    private String fileUrl;

    @SchemaEnum(implementation = StatusEnum.class)
    @Schema(name = "fileSource", description = "文件来源", type = "int")
    private Integer fileSource;

    @JsonSerialize(using = ToStringSerializer.class)
    @Schema(name = "storageId", description = "存储ID", type = "string")
    private Long storageId;

    @Schema(name = "fileThUrl", description = "文件缩略图URL", type = "string")
    private String fileThUrl;

    @SchemaEnum(implementation = StatusEnum.class)
    @Schema(name = "status", description = "文件状态", type = "int")
    private Integer status;

    @Schema(name = "remark", description = "备注", type = "string")
    private String remark;

    @Schema(name = "createTime", description = "创建时间", type = "string")
    @JsonFormat(pattern = DatePattern.NORM_DATETIME_PATTERN)
    private LocalDateTime createTime;

    public Long getFileId() {
        return fileId;
    }

    public void setFileId(Long fileId) {
        this.fileId = fileId;
    }

    public String getFileName() {
        return fileName;
    }

    public void setFileName(String fileName) {
        this.fileName = fileName;
    }

    public Long getFileSize() {
        return fileSize;
    }

    public void setFileSize(Long fileSize) {
        this.fileSize = fileSize;
    }

    public String getFileType() {
        return fileType;
    }

    public void setFileType(String fileType) {
        this.fileType = fileType;
    }

    public String getFileUrl() {
        return fileUrl;
    }

    public void setFileUrl(String fileUrl) {
        this.fileUrl = fileUrl;
    }

    public Integer getFileSource() {
        return fileSource;
    }

    public void setFileSource(Integer fileSource) {
        this.fileSource = fileSource;
    }

    public Long getStorageId() {
        return storageId;
    }

    public void setStorageId(Long storageId) {
        this.storageId = storageId;
    }

    public String getFileThUrl() {
        return fileThUrl;
    }

    public void setFileThUrl(String fileThUrl) {
        this.fileThUrl = fileThUrl;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public LocalDateTime getCreateTime() {
        return createTime;
    }

    public void setCreateTime(LocalDateTime createTime) {
        this.createTime = createTime;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        FileVO fileVO = (FileVO) o;
        return java.util.Objects.equals(fileId, fileVO.fileId) &&
               java.util.Objects.equals(fileName, fileVO.fileName) &&
               java.util.Objects.equals(fileSize, fileVO.fileSize) &&
               java.util.Objects.equals(fileType, fileVO.fileType) &&
               java.util.Objects.equals(fileUrl, fileVO.fileUrl) &&
               java.util.Objects.equals(fileSource, fileVO.fileSource) &&
               java.util.Objects.equals(storageId, fileVO.storageId) &&
               java.util.Objects.equals(fileThUrl, fileVO.fileThUrl) &&
               java.util.Objects.equals(status, fileVO.status) &&
               java.util.Objects.equals(remark, fileVO.remark) &&
               java.util.Objects.equals(createTime, fileVO.createTime);
    }

    @Override
    public int hashCode() {
        return java.util.Objects.hash(fileId, fileName, fileSize, fileType, fileUrl, fileSource, storageId, fileThUrl, status, remark, createTime);
    }

    @Override
    public String toString() {
        return "FileVO{" +
               "fileId=" + fileId +
               ", fileName='" + fileName + '\'' +
               ", fileSize=" + fileSize +
               ", fileType='" + fileType + '\'' +
               ", fileUrl='" + fileUrl + '\'' +
               ", fileSource=" + fileSource +
               ", storageId=" + storageId +
               ", fileThUrl='" + fileThUrl + '\'' +
               ", status=" + status +
               ", remark='" + remark + '\'' +
               ", createTime=" + createTime +
               '}';
    }

}
